﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.EShop.Common.Entity;
using Runda.EShop.Bll;

namespace Runda.EShop.Web.Message
{
    public partial class MessageView : BasePage
    {
        public Guid ID
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    return new Guid(Request.QueryString["ID"]);
                }
                else
                    return Guid.Empty;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SysMessageEntity entity = null;
                SysMessageBll bll = new SysMessageBll();
                entity = bll.Get<SysMessageEntity>(ID);

                lblCreatedAt.Text = entity.CreatedAt.ToString();
                lblTitle.Text = entity.Title;
                ltlContent.Text = entity.Content;

                if (entity.IsRead == 0)
                {
                    bll.ReadMessage(ID);
                }
            }
        }
    }
}